<template>
  <el-form :model="form" label-width="120px" inline>
    <el-row>
      <el-form-item
        v-for="item in searchConfig"
        :label="item.label"
        :key="item.value"
      >
        <component :is="item.component" v-model="form[item.value]"></component>
      </el-form-item>
      <slot></slot>
    </el-row>
  </el-form>
</template>

<script>
export default {
  props: {
    modal: {
      type: Object,
      required: true,
    },
    searchConfig: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {
      form: null,
    };
  },
  watch: {
    modal: {
      handler(val) {
        this.form = val;
      },
      immediate: true,
    },
    form: {
      handler() {
        this.$emit("form-change", this.form);
      },
      deep: true,
    },
  },
  computed: {},
};
</script>

<style></style>
